﻿using HZU.ZP.Data.Impl;
using HZU.ZP.Data.Interfaces;
using HZU.ZP.Domain.IService;
using HZU.ZP.Domain.Model;
using HZU.ZP.Domain.ServiceImpl.Mappers;
using System;
using System.Collections.Generic;
using System.Text;

namespace HZU.ZP.Domain.ServiceImpl.PCSvc
{
    public class CompanyService:ICompanyService
    {
        private CompanyMapper _mapper = new CompanyMapper();
        private ICompanyDao _sqlData;
        public CompanyService(ICompanyDao sqlData)
        {
            _sqlData = sqlData;
        }

        public Company GetByEmail(string email)
        {
            return _mapper.MapToDomain(_sqlData.GetByEmail(email));
        }

        public Company GetByName(string companyName)
        {
            return _mapper.MapToDomain(_sqlData.GetByName(companyName));
        }

        public Company GetByNumber(string companyNumber)
        {
            return _mapper.MapToDomain(_sqlData.GetByNumber(companyNumber));
        }

        public IList<Company> GetComList(int status, int pageIndex)
        {
            return _mapper.MapToDomainList(_sqlData.GetComList(status, pageIndex));
        }

        public int GetCount(int status)
        {
            return _sqlData.GetCount(status);
        }

        public Company GetId(int id)
        {
            return _mapper.MapToDomain(_sqlData.GetId(id));
        }

        public Company Login(Company company)
        {
            return _mapper.MapToDomain(_sqlData.Get(company));
        }

        public bool Register(Company company)
        {
            var companyDao = _mapper.MapToDao(company);
            _sqlData.Add(companyDao);
            return true;
        }

        public bool Update(Company company)
        {
            var companyDao = _mapper.MapToDao(company);
            _sqlData.Update(companyDao);
            return true;
        }
    }
}
